const Timestamp = new Date().getTime();
module.exports = {
    lintOnSave: false,
    configureWebpack: config => {
      config.externals = {
        'swiper': 'Swiper',
      },
      // js代码的压缩
      config.optimization.minimize = true;
    },
    css:{
      loaderOptions:{
        sass:{
          additionalData:`@import "./static/common.scss";`
        }
      }
    },
    chainWebpack: config => {
      if (process.env.NODE_ENV === 'production') {
          // 给js和css配置版本号
          config.output.filename('js/[name].' + Timestamp + '.js').end();
          config.output.chunkFilename('js/[name].' + Timestamp + '.js').end();
          config.plugin('extract-css').tap(args => [{
              filename: `css/[name].${Timestamp}.css`,
              chunkFilename: `css/[name].${Timestamp}.css`
          }])
      }
  },
    devServer: {
      overlay: {
        warning: false,
        errors: false,
      },
      historyApiFallback: true,
      proxy:{
        '/pro':{
          target:'https://api.szyoungwin.com:9000',
          changeOrigin:true,
          pathRewrite:{
            '^/pro':""
          }
        },
      }
    }  
}